home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
SGI Performance Co-Pilot 1.3
/
SGI Performance Co-Pilot 1.3.iso
/
dist
/
dist6.3
/
pcp.idb
/
usr
/
sbin
/
pmgenmap.z
/
pmgenmap
Wrap
Text File
|
1997-04-03
|
2KB
|
86 lines
#!/bin/sh
#
# Generate a Performance Metrics Name Space Map from a specification file
#
# $Header: /isms/pcp/pcp/1.3/src/pmgenmap/RCS/pmgenmap.sh,v 2.1 1997/03/26 02:53:17 kenmcd Exp $
#
prog=`basename $0`
if [ $# -gt 1 -o "X$1" = "X-?" ]
then
echo "Usage: $prog [infile]"
exit 1
fi
if [ $# -eq 0 ]
then
pathnamename="<stdin>"
name="<stdin>"
else
if [ ! -f $1 ]
then
echo "$prog: cannot open \"$1\""
exit 1
fi
pathname=`pwd`/$1
name=$1
fi
cat <<End-of-File
/*
* Performance Metrics Name Space Map
* Built by $prog from the file
* $name
* on `date`
*
* Do not edit this file!
*/
End-of-File
nawk <$1 '
$1 == "#" { if (comment) text = text "\n *"
comment++
for (i = 2; i <= NF; i++)
text = text " " $i
next
}
comment > 0 { if (comment == 1)
print "/*" text " */"
else
print "/*\n *" text "\n */"
comment = 0
text = ""
}
NF == 0 { print; next }
NF == 2 && $2 == "{" { if (state != 0) {
printf "[%s:%d] nested group?\n","'$1'",NR
exit 1
}
printf "char *%s[] = {\n",$1
state = 1
ord = 0
next
}
NF == 2 && state == 1 { printf "#define %s %d\n",$2,ord
ord++
printf " \"%s\",\n",$1
next
}
NF == 1 && $1 == "}" { printf "\n"
printf "};\n\n"
state = 0
next
}
{ printf "[%s:%d] syntax error\n","'$name'",NR
exit 1
}
END { if (state) {
printf "[%s:%d] unterminated group?\n","'$name'",NR
exit 1
}
if (comment == 1)
print "/*" text " */"
else if (comment > 1)
print "/*\n *" text "\n */"
}'